import React, { Component } from 'react';
import { Card, message, Table } from 'antd';

export default class Dating extends Component {

    state = {
        datingList: [],
    }

    initColumns = () => {
        this.columns = [
            {
                title: '活动名称',
                dataIndex: 'activityname',
            },
            {
                title: '活动地点',
                dataIndex: 'location',
            },
            {
                title: '有效时间',
                dataIndex: 'effectivetime',
            },
            {
                title: '人数',
                dataIndex: 'peoplenum',
            },
            {
                title: '内容',
                dataIndex: 'content',
            },
            {
                title: '真实姓名',
                dataIndex: 'realname',
            },
            {
                title: '微信号',
                dataIndex: 'contactvalue',
            },
            {
                title: '操作',
                width: 300,
                // render: (obj1) =>
                //     <span>
                //         <LinkButton
                //             onClick={() => {
                //                 MemoryUtils.artical = obj1;
                //                 this.props.history.push('/recommend/detail')
                //             }} >详情</LinkButton>
                //         <LinkButton onClick={() => {
                //             fetch('http://82.157.94.115:2005/deletecontent', {
                //                 method: 'POST',
                //                 body: JSON.stringify(obj1),
                //                 headers: {
                //                     'Content-Type': 'application/json;charset=utf-8'
                //                 }
                //             })
                //                 .then(res => res.json())
                //                 .then(res => {
                //                     message.success('删除成功！')
                //                     this.getArticals();
                //                 })
                //                 .catch(error => {
                //                     message.error('删除失败！')
                //                 })
                //         }}>删除</LinkButton>
                //     </span>
                
            },
        ]
    }

    getDatings = () => {
        fetch('http://82.157.94.115:2005/get_together')
            .then(res => res.json())
            .then(res => {
                this.setState({ datingList: res.togetherObj });
            })
    }

    componentWillMount() {
        this.initColumns();
    }

    componentDidMount() {
        this.getDatings();
    }

  render() {
    const { datingList} = this.state;
    return (
        <div>
        <Card>
            <Table
                bordered={true}
                columns={this.columns}
                dataSource={datingList}
                pagination={{ defaultPageSize: 10, showQuickJumper: true }}
            />
        </Card>
    </div>
    )
  }
}
